//
//  ASPracUnitSchoolActivitiesDetailVC.m
//  AttendenceSys
//
//  Created by 窦芳俊 on 2017/4/6.
//  Copyright © 2017年 窦芳俊. All rights reserved.
//

#import "ASPracUnitSchoolActivitiesDetailVC.h"

@interface ASPracUnitSchoolActivitiesDetailVC ()

@end


@implementation ASPracUnitSchoolActivitiesDetailVC

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    self.strNavTitle = @"活动详情";
    [self initView];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}

- (void)initView
{
    _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.backgroundColor = [UIColor clearColor];
    _tableView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height-49-15);
    _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [_tableView registerClass:[SchActivitiesSingeCell class] forCellReuseIdentifier:NSStringFromClass([SchActivitiesSingeCell class])];
    [self.view addSubview:_tableView];
    
    UIView *footer = [[UIView alloc] initWithFrame:CGRectMake(0, singleCellHeight*6/5, CGRectGetWidth(self.view.bounds), 100)];
    footer.backgroundColor = [UIColor clearColor];
    _tableView.tableFooterView = footer;
}

#pragma mark - UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}

- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    SchActivitiesSingeCell* cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([SchActivitiesSingeCell class])];
    
    [cell setBackgroundColor:[UIColor clearColor]];
    cell.nameLab.text = _actDetailInfo.userName;
    cell.timeLab.text = @"";
    cell.descLab.text = _actDetailInfo.actionDesc;
    
    if (0 < _actDetailInfo.imageUrlArr.count)
    {
        [cell initScrollView:_actDetailInfo.imageUrlArr];
        cell.descLab.frame = CGRectMake(cell.descLab.frame.origin.x,
                                        cell.descLab.frame.origin.y,
                                        cell.descLab.frame.size.width,
                                        50);
    }
    else
    {
        cell.descLab.frame = CGRectMake(cell.descLab.frame.origin.x,
                                        cell.descLab.frame.origin.y,
                                        cell.descLab.frame.size.width,
                                        singleCellHeight-35-(cell.actionTitleLab.frame.size.height+60));
    }
    
    cell.scanSignLab.text = [NSString stringWithFormat:@"报名参加人数: %@", _actDetailInfo.allInvitedNumber];
    cell.attendLab.text = [NSString stringWithFormat:@"扫码签到人数: %@", _actDetailInfo.allCheckedNumber];
    if (!_actDetailInfo.actionTitle)
    {
        _actDetailInfo.actionTitle = @"";
    }
    
    cell.actionTitleLab.text = [NSString stringWithFormat:@"活动标题: %@", _actDetailInfo.actionTitle];
    //cell.favorateNumLab.text = _actDetailInfo.favorateNum;
    [cell.headImageBtn setImageWithURL:_actDetailInfo.userPic placeholderImage:[UIImage imageNamed:@"portrait_default"]];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    [cell initActDetailInfoView];
    
    if (!_actDetailInfo.actionTime)
    {
        _actDetailInfo.actionTime = @"";
        cell.detailTime.text = @"";
    }
    else
    {
        if ([_actDetailInfo.actionTime length] == 19)
        {
            cell.detailTime.text = [NSString stringWithFormat:@"活动时间：%@",
                                    [_actDetailInfo.actionTime substringToIndex:([_actDetailInfo.actionTime length]-3)]];
        }
        else
        {
            cell.detailTime.text = [NSString stringWithFormat:@"活动时间：%@", _actDetailInfo.actionTime];
        }
    }
    
    if (!_actDetailInfo.sponsor)
    {
        _actDetailInfo.sponsor = @"";
    }
    
    if (!_actDetailInfo.actionArea)
    {
        _actDetailInfo.actionArea = @"";
    }
    
    cell.sponsorLab.text = [NSString stringWithFormat:@"主办方：%@", _actDetailInfo.sponsor];;
    cell.areaLab.text = [NSString stringWithFormat:@"地点：%@", _actDetailInfo.actionArea];
    cell.voteNumLab.text = [NSString stringWithFormat:@"%@人感兴趣", _actDetailInfo.voteNum];
    //[cell initfavHeadScrollView:_actDetailInfo.imageUrlArr];
    
    return cell;
}

#pragma mark - UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return singleCellHeight*6/5;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

@end


